package com.fms.gui.templateCreator.components.button;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import com.fms.model.domain.FlowSheet;
import com.fms.model.factory.IFlowSheetFactory;
import com.fms.model.repository.IFlowSheetRepository;

public class CreateSheetTemplateButton extends JButton implements ActionListener
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 252746807875597622L;
	private IFlowSheetFactory factory;
	private IFlowSheetRepository flowSheetRepo;
	
	public CreateSheetTemplateButton(IFlowSheetFactory _flowSheetFactory,
									 IFlowSheetRepository _flowSheetRepo)
	{
		this.flowSheetRepo = _flowSheetRepo;
		this.factory = _flowSheetFactory;
		this.addActionListener(this);
		this.setText("Create A Flow Sheet");
	}

	public void actionPerformed(ActionEvent arg0)
	{
		FlowSheet sheet = factory.newSheet();
		
		if(sheet != null)
		{
			flowSheetRepo.saveAsNew(sheet);
		}
				
	}


}
